import { LockKeyEnum } from '@/enums'
import { sessionCache } from '@/utils/storageCache'
import { defineStore } from 'pinia'

const useCommonStore = defineStore('common', {
  state: (): ICommon => ({
    // 无操作计时时间
    lockTime: 0,
    // 是否为锁屏状态
    isLock: sessionCache.getCache(LockKeyEnum.LOCK_STATUS_KEY) || false,
  }),
  actions: {
    updatelockTime(lockTime: number) {
      this.lockTime = lockTime
    },
    updateisLock(isLock: boolean) {
      this.isLock = isLock
      sessionCache.setCache(LockKeyEnum.LOCK_STATUS_KEY, isLock)
    }
  }
})

export default useCommonStore